'*******************************************************************************
' *  
' *  Product: GSALib
' *  Description: A C# API for accessing the Google Search Appliance.
' *
' *  (c) Copyright 2008 Michael Cizmar + Associates Ltd.  (MC+A)
' *  
'*******************************************************************************


Imports System
Imports System.Collections.Generic
Imports System.Collections
Imports System.Text
Imports GSALibVB.GSALib.Constants

Namespace GSALib.GSA
    ''' <summary>
    ''' Class for creating Response object based on returned results of GSA
    ''' <para>Author Albert Ghukasyan</para>
    ''' </summary>
    Public NotInheritable Class Response
#Region "Variables"

        Private searchTime As Double
        Private query As String
        Private parameters As New Hashtable()
        Private startIndex As Long
        Private endIndex As Long
        Private numResults As Long
        Private isFiltered As Boolean
        Private previousResponseUrl As String
        Private nextResponseUrl As String
        Private searchComments As String
        Private spelling As Spelling
        Private synonyms As New ArrayList()
        Private keyMatches As New ArrayList()
        Private results As New ArrayList()
        Private oneboxResponses As New ArrayList()

#End Region

#Region "Constructor"

        Friend Sub New()
        End Sub

#End Region

#Region "Get/Set Properties"

        Public Function getEndIndex() As Long
            Return endIndex
        End Function

        Public Sub setEndIndex(ByVal endIndex As Long)
            Me.endIndex = endIndex
        End Sub

        Public Function getIsFiltered() As Boolean
            Return isFiltered
        End Function

        Public Sub setFiltered(ByVal filtered As Boolean)
            isFiltered = filtered
        End Sub

        Public Sub setResults(ByVal results As ArrayList)
            Me.results = results
        End Sub

        Public Sub setKeyMatches(ByVal _keyMatches As ArrayList)
            Me.keyMatches = _keyMatches
        End Sub

        Public Function getKeyMatches() As ArrayList
            Return Me.keyMatches
        End Function

        Public Function getPreviousResponseUrl() As String
            Return previousResponseUrl
        End Function

        Public Sub setPreviousResponseUrl(ByVal previousResponseUrl As String)
            Me.previousResponseUrl = previousResponseUrl
        End Sub

        Public Function getNextResponseUrl() As String
            Return nextResponseUrl
        End Function

        Public Sub setNextResponseUrl(ByVal nextResponseUrl As String)
            Me.nextResponseUrl = nextResponseUrl
        End Sub

        Public Function getSearchComments() As String
            Return searchComments
        End Function

        Public Sub setSearchComments(ByVal SearchComments As String)
            Me.searchComments = SearchComments
        End Sub

        Public Function getOneBoxResponses() As ArrayList
            Return oneboxResponses
        End Function

        Public Sub setOneBoxResponses(ByVal oneboxResponses As ArrayList)
            Me.oneboxResponses = oneboxResponses
        End Sub

        Public Sub addOneBoxResponse(ByVal oneboxResponse As OneBoxResponse)
            Me.oneboxResponses.Add(oneboxResponse)
        End Sub

        Public Function getSpelling() As Spelling
            Return spelling
        End Function

        Public Sub setSpelling(ByVal spelling As Spelling)
            Me.spelling = spelling
        End Sub

        Public Function getSynonymsWithMarkup() As ArrayList
            Return synonyms
        End Function

        Public Sub addSynonymWithMarkup(ByVal synonym As String)
            synonyms.Add(synonym)
        End Sub

        Public Function getQuery() As String
            Return query
        End Function

        Public Sub setQuery(ByVal query As String)
            Me.query = query
        End Sub

        Public Function getNumResults() As Long
            Return numResults
        End Function

        Public Sub setNumResults(ByVal numResults As Long)
            Me.numResults = numResults
        End Sub

        Public Function getParams() As Hashtable
            Return Me.parameters
        End Function

        Public Sub setParams(ByVal parameters As Hashtable)
            Me.parameters = parameters
        End Sub

        Public Sub putParam(ByVal name As String, ByVal value As String)
            parameters.Add(name, value)
        End Sub

        Public Function getSearchTime() As Double
            Return searchTime
        End Function

        Public Sub setSearchTime(ByVal searchTime As Double)
            Me.searchTime = searchTime
        End Sub

        Public Function getStartIndex() As Long
            Return startIndex
        End Function

        Public Sub setStartIndex(ByVal startIndex As Long)
            Me.startIndex = startIndex
        End Sub

        Public Function getResults() As ArrayList
            Return results
        End Function

#End Region

#Region "ToString"

        Public Overloads Overrides Function ToString() As String
            Dim buf As New StringBuilder()

            Dim indent As String = ""
            buf.Append(indent).Append("searchTime=").Append(searchTime).Append("" & Chr(10) & "")
            buf.Append(indent).Append("query=").Append(query).Append("" & Chr(10) & "")
            buf.Append(indent).Append("startIndex=").Append(startIndex).Append("" & Chr(10) & "")
            buf.Append(indent).Append("endIndex=").Append(endIndex).Append("" & Chr(10) & "")
            buf.Append(indent).Append("numResults=").Append(numResults).Append("" & Chr(10) & "")
            buf.Append(indent).Append("isFiltered=").Append(isFiltered).Append("" & Chr(10) & "")
            buf.Append(indent).Append("nextResponseUrl=").Append(nextResponseUrl).Append("" & Chr(10) & "")
            buf.Append(indent).Append("results=").Append(results).Append("" & Chr(10) & "")
            buf.Append(indent).Append("params=").Append(parameters).Append("" & Chr(10) & "")

            Return buf.ToString()
        End Function

#End Region
    End Class
End Namespace
